<?php
/**
 * desc Created by wang.
 * User: wang
 * motto: 是时候为小时候吹过的牛而努力了!
 * Date: 2020/3/17 12:40
 */

namespace app\common\lib;


class Show
{
    /**
     * 功能说明 返回给客户端数据格式
     * @author: wang
     * @Date: 2020/3/17 10:59
     * @param $status
     * @param string $message
     * @param array $data
     * @param int $httpStatus
     * @return \think\response\Json
     */
    public function show($code, $msg = 'error', $data = [], $httpStatus = 200)
    {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'data' => $data
        ];
        return json($result, $httpStatus);
    }

    /**
     * 功能说明 返回给ajax请求的数据格式
     * @author: wang
     * @Date: 2020/3/17 11:05
     * @param $code
     * @param string $msg
     * @param array $data
     * @param null $url
     * @return \think\response\Json
     */
    public function result($code, $msg = 'error', $data = [], $url = null)
    {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
            'url'  => $url,
        ];
        return json($result);
    }
}